﻿<inter:PluginConfigForm x:Class="Convertor.Plugin.AlertBox.ConfigForm"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:sm="clr-namespace:Wpf.CommonTools.SystemExtension;assembly=Wpf.CommonTools"
             xmlns:conv="clr-namespace:Wpf.CommonTools.Converter;assembly=Wpf.CommonTools"
             xmlns:local="clr-namespace:Convertor.Plugin.AlertBox"
             xmlns:sys="clr-namespace:System;assembly=mscorlib"
             xmlns:regex="clr-namespace:System.Text.RegularExpressions;assembly=System"
             xmlns:inter="clr-namespace:Convertor.Interface;assembly=Convertor.Interface"
             mc:Ignorable="d">
    <inter:PluginConfigForm.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Convertor;component\Assets\Style.xaml"/>
                <ResourceDictionary Source="Assets\Lang\StringResource.zh.xaml"/>
                <ResourceDictionary Source="Assets\Lang\StringResource.en.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <conv:EnumToVsibleConverter x:Key="EnumToVsibleConverter"/>
            <conv:FindUILanguageConverter x:Key="FindUILanguageConverter"/>

            <ObjectDataProvider x:Key="AlertTypes" 
                        MethodName="GetValues" ObjectType="{x:Type sys:Enum}">
                <ObjectDataProvider.MethodParameters>
                    <x:Type TypeName="local:AlertTypes"/>
                </ObjectDataProvider.MethodParameters>
            </ObjectDataProvider>
            <ObjectDataProvider x:Key="MessageBoxButtonTypes" 
                        MethodName="GetValues" ObjectType="{x:Type sys:Enum}">
                <ObjectDataProvider.MethodParameters>
                    <x:Type TypeName="local:MessageBoxButtonTypes"/>
                </ObjectDataProvider.MethodParameters>
            </ObjectDataProvider>
        </ResourceDictionary>
    </inter:PluginConfigForm.Resources>
    <DockPanel MinWidth="400" MaxHeight="600" DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type inter:PluginConfigForm}}, Path=Config}" >
        <AdornerDecorator DockPanel.Dock="Top">
            <ComboBox Name="cbReturnType"
                      ItemsSource="{Binding Source={StaticResource AlertTypes}}"
                      SelectedItem="{Binding Path=AlertType}" >
                <ComboBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Path=., Converter={StaticResource FindUILanguageConverter}, ConverterParameter='Plugin_AlertBox_AlertType_'}"/>
                    </DataTemplate>
                </ComboBox.ItemTemplate>
                <sm:WatermarkService.Titlemark>
                    <TextBlock Text="{DynamicResource Plugin_AlertBox_AlertType}" TextAlignment="Right" VerticalAlignment="Bottom"></TextBlock>
                </sm:WatermarkService.Titlemark>
            </ComboBox>
        </AdornerDecorator>
        <AdornerDecorator DockPanel.Dock="Top"
                          Visibility="{Binding ElementName=cbReturnType, Path=SelectedItem, Converter={StaticResource EnumToVsibleConverter}, ConverterParameter={x:Static local:AlertTypes.CustomContent}}">
            <TextBox MinHeight="200" MaxHeight="400" MaxWidth="600" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto"
                         Text="{Binding Path=CustomContent, UpdateSourceTrigger=PropertyChanged}"
                         AcceptsReturn="True" AcceptsTab="True">
                <sm:WatermarkService.Titlemark>
                    <TextBlock Text="{DynamicResource Plugin_AlertBox_CustomContent}" TextAlignment="Right" VerticalAlignment="Bottom"></TextBlock>
                </sm:WatermarkService.Titlemark>
            </TextBox>
        </AdornerDecorator>
        <TextBlock Style="{StaticResource InfoStyle}" DockPanel.Dock="Top" Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type inter:PluginConfigForm}}, Path=Config.ToolTip}"/>
    </DockPanel>
</inter:PluginConfigForm>
